#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections.Generic;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;

using Osh.Scripting;

namespace Osh
{
	public abstract class OshHostBase : IOshHost
	{
		private static OshHostBase _current;

		private ServiceRegistry _services = new ServiceRegistry();
		private IScriptTraceSource _scriptTraceSource;

		public OshHostBase()
		{
			this.Services.RegisterService(new Formatter());
		}

		#region IOshHost Members
		public abstract IOsh Osh { get; }

		public abstract object InvokeScript(string scriptName, params object[] args);

		public IScriptTraceSource ScriptTraceSource
		{
			get
			{
				if(_scriptTraceSource == null)
					_scriptTraceSource = new ScriptTraceSource("Osh.Scripting");
				return _scriptTraceSource;
			}
			protected set { _scriptTraceSource = value; }
		}
		#endregion

		#region IServiceRegistryProvider
		public IServiceRegistry Services
		{
			get { return _services; }
		}
		#endregion IServiceRegistryProvider

		public static OshHostBase Current
		{
			get { return _current; }
			set { _current = value; }
		}
	}
}
